package com.usc.blog.web.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.usc.blog.pojo.BlogData;
import com.usc.blog.pojo.User;
import com.usc.blog.service.BlogDataService;
import com.usc.blog.service.UserService;

/**
 *
 * @版权: Copyright (c) 2016-2017 *********公司技术开发部
 * @author : huangjiapeng
 * @E-mail:1625545295@qq.com
 * @版本: 1.0
 * @创建日期: 2019年4月17日 上午10:40:12
 * @ClassName UserController
 * @类描述-Description: TODO
 * @修改记录:
 * @版本: 1.0
 */
@Controller
@RequestMapping("user")
public class UserController {
	@Autowired
	UserService userService;

	@Autowired
	public BlogDataService blogDataService;

	@RequestMapping(value = "toBlogUI/{blogdataid}") // , method =
														// RequestMethod.GET
	public String toBlogUI(@PathVariable("blogdataid") String blogdataid, HttpServletRequest request,
			HttpServletResponse response, Model model, HttpSession session) {
		// 当前用户
		User user = (User) session.getAttribute("currentUser");
		model.addAttribute("user", user);
		System.out.println("user=" + user);
		// 博客
		System.out.println("blogdataid=" + blogdataid);
		BlogData blogData = blogDataService.selectByPrimaryKey(blogdataid);
		System.out.println("blogData=" + blogData);
		model.addAttribute("blogData", blogData);
		return "user/blogcontent";
	}
}
